import java.util.Stack;

public class Test {
    class Solution {
        public boolean isoperation(String s){
            if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/")){

                return true;
            }else {
                return false;
            }
        }
        public int evalRPN(String[] tokens) {
            Stack<Integer> stack = new Stack<>() ;
            for (String c:tokens) {
                if(!isoperation(c)){
                    int x = Integer.parseInt(c);
                    stack.push(x);
                }else {
                    int val2 = stack.pop();
                    int val1 = stack.pop();
                    switch (c){
                        case "+":stack.push(val1+val2);
                        break;
                        case "-":stack.push(val1-val2);
                        break;
                        case "*":stack.push(val1*val2);
                        break;
                        case "/":stack.push(val1/val2);
                        break;
                    }
                }
            }
            return stack.pop();
        }
        public boolean IsPopOrder (int[] pushV, int[] popV) {
            Stack <Integer> stack = new Stack<>();
            int j = 0;
            for (int i = 0; i < pushV.length; i++) {
                stack.push(pushV[i]);
                while(!stack.empty()&&j < popV.length&&stack.peek() == popV[j]){
                    stack.pop();
                    j++;
                }
            }
            return stack.empty() ;
        }
        public boolean isValid(String s) {
            Stack<Character> stack = new Stack();
            for(int i = 0;i<s.length();i++){
                char c1 = s.charAt(i);
                if(c1 == '(' || c1 == '[' || c1 == '{'){
                    stack.push(c1);
                }else {
                    if(stack.empty()){
                        return false;
                    }
                    char c2 = stack.peek();
                    if(c1 == ')' && c2 == '('|| c1 == '}' && c2 == '{'|| c1 == ']' && c2 == '['){
                        stack.pop();
                    }else {
                        return false;
                    }
                }
            }
            if(!stack.empty()){
                return false;
            }

            return true;
        }
    }
    public static void main2(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(11);
        stack.push(12);
        stack.push(13);
        stack.push(14);
        System.out.println(stack);
        System.out.println(stack.size());
        System.out.println(stack.peek());
        stack.pop();
    }
    public static void main1(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(11);
        myStack.push(12);
        myStack.push(13);
        myStack.push(14);
        System.out.println(myStack);//打印栈的元素
        System.out.println(myStack.pop());//打印栈顶的元素 , 并将栈顶元素取出
        System.out.println(myStack);
        System.out.println(myStack.peek());//打印栈顶的元素
    }
}
